<script>
	const updateManager = uni.getUpdateManager();
	export default {
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			let port = uni.getSystemInfoSync().platform
      console.log('App Show platform:',port)
			switch (port) {
				case 'android':
					console.log('Android'); //android
					break;
				case 'ios':
					console.log('iOS'); //ios
					break;
				default:
					console.log('小程序'); //devtools
					break;
			}
      this.checkUpdate();
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			checkUpdate() {
				// 当向小程序后台请求完新版本信息，会进行回调。res: {hasUpdate: true, version: 1.0.0}
				updateManager.onCheckForUpdate(function(res) {
					console.log("res", res)
					if (res.hasUpdate) { // 有更新
						uni.showLoading({
							title: '更新中...'
						}); // 开始下载前，显示Loading
					}
				});
				// 当新版本下载完成，会进行回调
				updateManager.onUpdateReady(function() {
					uni.hideLoading(); // 关闭 Loading
					uni.showModal({ // 弹确认框（强制更新）
						title: '更新提示',
						content: '新版本已经下载完成，是否立即重启应用以完成更新？',
						success: function(res) {
							if (res.confirm) {
								updateManager.applyUpdate(); // 强制小程序重启并使用新版本。
							}
						}
					})
				});
				// 当新版本下载失败，会进行回调
				updateManager.onUpdateFailed(function() {
					uni.hideLoading(); // 关闭 Loading
					uni.showToast({
						title: '更新失败，稍后再试...',
						icon: "error"
					});
				});
			}
		}
	}
</script>

<style>
	@import './iconfont/iconfont.css';
  @import "./css/common.css";

	.indexContentHeight {
		/* height: 69vh; */
	}

	.uni-page-wrapper {
		overflow-x: hidden !important
	}

	/*每个页面公共css */
	.bottomImg {
		width: 50rpx;
		height: 20rpx;
		background-color: #00f
	}

	.indexContent {
		width: 720rpx;
		height: auto;
		/* height: 100%; */
		/* height:65vh; */
		/* border:solid #8F8F94; */
		border-radius: 25rpx 25rpx 0rpx 0rpx;
		background-color: #fff;
		/* box-shadow:0rpx 0rpx 10rpx 0rpx #8f8f94; */
		border-left: 1rpx solid #F7FAFB;
		border-right: 1rpx solid #F7FAFB;
		position: absolute;
		/*  #ifndef  MP-WEIXIN */
		top: 220rpx;
		/*  #endif  */
		/*	#ifdef  MP-WEIXIN */
		top: 220rpx;
		/*  #endif  */
		left: 15rpx;
		padding-bottom: 150rpx
	}

	.logoSty {
		/*   position:relative;left:20rpx;bottom:-120rpx;
		    background-image:url('./static/pic/logo1.png');
		    background-repeat:no-repeat;width:680rpx;
			height:53rpx;background-size:100% */
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		/* overflow: scroll; */
		overflow-y: scroll;
		overflow-x: hidden
	}

	uni-checkbox .uni-checkbox-input {
		width: 30rpx;
		height: 30rpx;
		border: 2rpx solid #8f8f94;
		border-radius: 10rpx
	}

	.attdenanceSty {
		margin: auto;
		margin-top: 40upx;
		width: 605upx;
		height: 72upx;
		display: flex;
		justify-content: space-between;
		background-color: #FF0088;
		color: white;
		padding-top: 30upx;
		font-size: 32upx;
		border-radius: 20rpx;
	}

	.Popup {
		height: 100vh;
		background-color: white;
		overflow: auto;
		margin-bottom: 50rpx;
		width: 50vw;
		border-radius: 20rpx;


		/* 	width: 183rpx;
		height: 265rpx;
		background-color: white;
		position: absolute;
		top: 230rpx;
		left: 455rpx;
		border-radius: 10rpx;
		border: 1rpx solid #888;
		z-index: 9999;
		overflow: auto; */
	}
</style>
